package com.alibaba.shopping_goods_service.service;

import com.alibaba.shopping_common.pojo.SeckillGoods;
import com.alibaba.shopping_common.service.SeckillGoodsService;
import com.alibaba.shopping_goods_service.mapper.SeckillGoodsMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName SeckillGoodsServiceImpl
 * @Description TODO
 * @Author Leo
 * @Date 2024/12/10 20:41
 */
@DubboService
@Transactional
public class SeckillGoodsServiceImpl implements SeckillGoodsService {

    @Autowired
    private SeckillGoodsMapper seckillGoodsMapper;

    /**
     * 新增秒杀商品
     * @param seckillGoods
     */
    @Override
    public void add(SeckillGoods seckillGoods) {
        seckillGoodsMapper.insert(seckillGoods);
    }

    /**
     * 更新
     * @param seckillGoods
     */
    @Override
    public void update(SeckillGoods seckillGoods) {
        seckillGoodsMapper.updateById(seckillGoods);
    }

    /**
     * 分页查询
     * @param page
     * @param size
     * @return
     */
    @Override
    public Page<SeckillGoods> findPage(int page, int size) {
        return seckillGoodsMapper.selectPage(new Page<>(page,size),null);
    }
}




